<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2009 Christian Kartnig <office@hahnepeter.de>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 * Hint: use extdeveval to insert/update function index above.
 */

require_once(t3lib_extMgm::extPath('topstip').'lib/class.topstip_pibase.php');


/**
 * Plugin 'formidable_test' for the 'test' extension.
 *
 * @author	Christian <office@hahnepeter.de>
 * @package	TYPO3
 * @subpackage	tx_test
 */
class tx_topstip_pi2 extends topstip_pibase {
	var $prefixId      = 'tx_topstip_pi2';		// Same as class name
	var $scriptRelPath = 'pi2/class.tx_topstip_pi2.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'topstip';	// The extension key.
	var $pi_checkCHash = false;

	/**
	 * @var t3lib_DB $db
	 */
	var $db;
	/**
	 * The main method of the PlugIn
	 *
	 * @param	string		$content: The PlugIn content
	 * @param	array		$conf: The PlugIn configuration
	 * @return	The content that is displayed on the website
	 */
	function main($content, $conf) {
		$this->conf = $conf;
		$this->db = $GLOBALS['TYPO3_DB'];
		$this->pi_setPiVarDefaults();
    $cache =0;
    $this->pi_USER_INT_obj = 1 ; 
		//$this->pi_loadLL();

		$this->pi_initPIflexForm();

		$this->dbTable = $this->getPluginParam('dbTable');

		$this->oForm = t3lib_div::makeInstance("tx_ameosformidable");
		$this->oForm->init(
			$this,	// reference to the current plugin object
			"EXT:topstip/pi2/xml/searchform.xml" // soft-path to xml file
		);

		return $this->oForm->render();
	}

	
	public function getStatusDropdownItems(){
		$states = $this->db->exec_SELECTgetRows('*', 'tx_kbks_status', 'deleted=0');
		$items = array();
		foreach($states as $state){
			$items[] = array(
				"caption" => $state['tx_kbks_titel'],
				"value" => $state['uid'],
				);
		}
		return $items;
	}

	public function getListSql(){
		$fields = "t.crdate, tx_kbks_vorname,
					tx_kbks_nachname,
					tx_kbks_svnr, tx_kbks_ergebnis
				";
		$where = "t.deleted = 0";
		$query = $this->getQuery($fields, $where);
		return $query;
	}
	
	
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/topstip/pi2/class.tx_test_pi2.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/topstip/pi2/class.tx_test_pi2.php']);
}

?>